<% layout('/layouts/default.html', {title: '商品列表', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text('商品列表')}
			</div>
			<div class="box-tools pull-right">
				<div class="btn-group">
					<a href="javascript:" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
						<i class="fa fa-refresh"></i>刷新规则定价<span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<li><a href="javascript:" onclick="priceUpdate(0)"><i class="fa fa-refresh"></i>全部</a></li>
						<li><a href="javascript:" onclick="priceUpdate(1)"><i class="fa fa-refresh"></i>上架</a></li>
						<li><a href="javascript:" onclick="priceUpdate(2)"><i class="fa fa-refresh"></i>下架</a></li>
						<li><a href="javascript:" onclick="priceUpdate(3)"><i class="fa fa-refresh"></i>备上架</a></li>
						<li><a href="javascript:" onclick="priceUpdate(4)"><i class="fa fa-refresh"></i>自动下架</a></li>
					</ul>
				</div>
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('ztBeiGoods:ztBeiGoodsData:edit')){ %>
				<a href="#" class="btn btn-default" id="btnTag" title="${text('批量更换定价')}"><i class="fa fa-angle-double-down"></i> ${text('批量更换定价')}</a>
				<a href="#" class="btn btn-default" id="btnDelUser" title="商品批量上架"><i class="fa fa-filter"></i> 批量上架</a>
				<div class="btn-group">
					<a href="javascript:" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
						 添加分类<span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<li><a href="javascript:" id="btnAddType">分类</a></li>
						<li><a href="javascript:" id="btnAddHaoz">特色专区</a></li>
						<li><a href="javascript:" id="btnAddHaow">走心推荐</a></li>
						<li><a href="javascript:" id="btnAddZhuanc">专场</a></li>
						<li><a href="javascript:" id="btnAddBanner">首页轮播</a></li>
						<li><a href="javascript:" id="btnAddJinxuan">精选</a></li>
					</ul>
				</div>
				
				<div class="btn-group">
					<a href="javascript:" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
						 删除分类<span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<li><a href="javascript:" id="btnDelType">分类</a></li>
						<li><a href="javascript:" id="btnDelHaoz">特色专区</a></li>
						<li><a href="javascript:" id="btnDelHaow">走心推荐</a></li>
						<li><a href="javascript:" id="btnDelZhuanc">专场</a></li>
						<li><a href="javascript:" id="btnDelBanner">首页轮播</a></li>
						<li><a href="javascript:" id="btnDelJinxuan">精选</a></li>
					</ul>
				</div>
					<a href="${ctx}/ztBeiGoods/form" class="btn btn-default btnTool" title="${text('新增商品')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${ztGoods}" action="${ctx}/ztBeiGoods/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('商品渠道')}：</label>
					<div class="control-inline width-90">
						<#form:select path="spotid" dictType="zt_spotid_type" blankOption="true" class="form-control width-80" />
					</div>
				</div>							
				<div class="form-group">
					<label class="control-label">${text('栏目类型')}：</label>
					<div class="control-inline width-120">
						<#form:select path="goodstemp" dictType="zt_goodstemp_type" blankOption="true" class="form-control width-120"/>
					</div>
				</div>
				
				
				
				<!-- <div class="form-group">
					<label class="control-label">${text('上架状态')}：</label>
					<div class="control-inline width-90">
						<#form:select path="sjStatus" dictType="zt_sj_type" blankOption="true" class="form-control width-90"/>
					</div>
				</div> -->
				
				<div class="form-group">
					<label class="control-label">${text('分类筛选')}：</label>
					
					<div class="control-inline width-270">
							<select name='oneType' style="width:auto;min-width: 90px;padding:6px;border-color:#d2d6de"></select>
							<select name='twoType' style="width:auto;min-width: 90px;padding:6px;border-color:#d2d6de"></select>
							<select name='threeType' style="width:auto;min-width: 90px;padding:6px;border-color:#d2d6de"></select>
					</div>
					
				</div>
			
				
				
				<div class="form-group">
					<label class="control-label">商品名：</label>
					<div class="control-inline">
						<#form:input path="title" maxlength="500" class="form-control width-200"/>
					</div>
				</div>
				
				<div class="form-group">
					<label class="control-label">${text('品牌')}：</label>
					<div class="control-inline width-120">
						<#form:select name="brandid" items="${brandList}"
							itemLabel="name" itemValue="id" blankOption="true" class="form-control width-120"/>
					</div>
				</div>
				
				
				<div class="form-group">
					<label class="control-label">商品编号：</label>
					<div class="control-inline">
						<#form:input path="code" maxlength="25" class="form-control width-90" onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');"/>
						
					</div>
				</div>
				
				<div class="form-group">
					<label class="control-label">折扣：</label>
					<div class="control-inline">
						<#form:input path="depo_gte" maxlength="8" class="form-control width-90" onkeyup="this.value=this.value.replace(/[^0-9-.-]+/,'');"/>
						&nbsp;--&nbsp;<#form:input path="depo_lte" maxlength="8" class="form-control width-90" onkeyup="this.value=this.value.replace(/[^0-9-.-]+/,'');"/>
					</div>
				</div>
				
				<div class="form-group">
					<label class="control-label">差额：</label>
					<div class="control-inline">
						<#form:input path="diff_gte" maxlength="8" class="form-control width-90" onkeyup="this.value=this.value.replace(/[^0-9-.-]+/,'');"/>
						&nbsp;--&nbsp;<#form:input path="diff_lte" maxlength="8" class="form-control width-90" onkeyup="this.value=this.value.replace(/[^0-9-.-]+/,'');"/>
					</div>
				</div>
				
				<div class="form-group">
					<label class="control-label">协议价：</label>
					<div class="control-inline">
						<#form:input path="supplyPrice_gte" maxlength="8" class="form-control width-90" onkeyup="this.value=this.value.replace(/[^0-9-.-]+/,'');"/>
						&nbsp;--&nbsp;<#form:input path="supplyPrice_lte" maxlength="8" class="form-control width-90" onkeyup="this.value=this.value.replace(/[^0-9-.-]+/,'');"/>
					</div>
				</div>
				
				<div class="form-group">
					<label class="control-label">${text('定价模式')}：</label>
					<div class="control-inline width-120">
						<#form:select path="tag" dictType="zt_tag_type" blankOption="true" class="form-control width-120"/>
					</div>
				</div>
				
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>

$('#btnAddType').click(function(){
	var userCodes = $('#dataGrid').dataGrid('getSelectRows');
	if (userCodes != null && userCodes.length > 0){
		js.confirm('确认要商品添加归类吗？', function(){
			js.ajaxSubmit('${ctx}/ztBeiGoods/btnAddType', {
				goodsString : userCodes.join(','),
				temp:"0"
			}, function(data){
				js.showMessage(data.message);
				page();
			});
		});
	}else{
		js.showMessage('请在列表选中要确定归类 的商品');
	}
	return false;
});

$('#btnAddHaoz').click(function(){
	var userCodes = $('#dataGrid').dataGrid('getSelectRows');
	if (userCodes != null && userCodes.length > 0){
		js.confirm('确认要商品添加归类吗？', function(){
			js.ajaxSubmit('${ctx}/ztBeiGoods/btnAddType', {
				goodsString : userCodes.join(','),
				temp:"1"
			}, function(data){
				js.showMessage(data.message);
				page();
			});
		});
	}else{
		js.showMessage('请在列表选中要确定归类 的商品');
	}
	return false;
});
$('#btnAddHaow').click(function(){
	var userCodes = $('#dataGrid').dataGrid('getSelectRows');
	if (userCodes != null && userCodes.length > 0){
		js.confirm('确认要商品添加归类吗？', function(){
			js.ajaxSubmit('${ctx}/ztBeiGoods/btnAddType', {
				goodsString : userCodes.join(','),
				temp:"2"
			}, function(data){
				js.showMessage(data.message);
				page();
			});
		});
	}else{
		js.showMessage('请在列表选中要确定归类 的商品');
	}
	return false;
});
$('#btnAddZhuanc').click(function(){
	var userCodes = $('#dataGrid').dataGrid('getSelectRows');
	if (userCodes != null && userCodes.length > 0){
		js.confirm('确认要商品添加归类吗？', function(){
			js.ajaxSubmit('${ctx}/ztBeiGoods/btnAddType', {
				goodsString : userCodes.join(','),
				temp:"3"
			}, function(data){
				js.showMessage(data.message);
				page();
			});
		});
	}else{
		js.showMessage('请在列表选中要确定归类 的商品');
	}
	return false;
});
$('#btnAddBanner').click(function(){
	var userCodes = $('#dataGrid').dataGrid('getSelectRows');
	if (userCodes != null && userCodes.length > 0){
		js.confirm('确认要商品添加归类吗？', function(){
			js.ajaxSubmit('${ctx}/ztBeiGoods/btnAddType', {
				goodsString : userCodes.join(','),
				temp:"4"
			}, function(data){
				js.showMessage(data.message);
				page();
			});
		});
	}else{
		js.showMessage('请在列表选中要确定归类 的商品');
	}
	return false;
});

$('#btnDelType').click(function(){
	var userCodes = $('#dataGrid').dataGrid('getSelectRows');
	if (userCodes != null && userCodes.length > 0){
		js.confirm('确认要商品删除归类吗？', function(){
			js.ajaxSubmit('${ctx}/ztBeiGoods/btnDelType', {
				goodsString : userCodes.join(','),
				temp:"0"
			}, function(data){
				js.showMessage(data.message);
				page();
			});
		});
	}else{
		js.showMessage('请在列表选中要确定归类 的商品');
	}
	return false;
});

$('#btnDelHaoz').click(function(){
	var userCodes = $('#dataGrid').dataGrid('getSelectRows');
	if (userCodes != null && userCodes.length > 0){
		js.confirm('确认要商品删除归类吗？', function(){
			js.ajaxSubmit('${ctx}/ztBeiGoods/btnDelType', {
				goodsString : userCodes.join(','),
				temp:"1"
			}, function(data){
				js.showMessage(data.message);
				page();
			});
		});
	}else{
		js.showMessage('请在列表选中要确定归类 的商品');
	}
	return false;
});
$('#btnDelHaow').click(function(){
	var userCodes = $('#dataGrid').dataGrid('getSelectRows');
	if (userCodes != null && userCodes.length > 0){
		js.confirm('确认要商品删除归类吗？', function(){
			js.ajaxSubmit('${ctx}/ztBeiGoods/btnDelType', {
				goodsString : userCodes.join(','),
				temp:"2"
			}, function(data){
				js.showMessage(data.message);
				page();
			});
		});
	}else{
		js.showMessage('请在列表选中要确定归类 的商品');
	}
	return false;
});

$('#btnAddJinxuan').click(function(){
	var userCodes = $('#dataGrid').dataGrid('getSelectRows');
	if (userCodes != null && userCodes.length > 0){
		js.confirm('确认要商品添加归类吗？', function(){
			js.ajaxSubmit('${ctx}/ztTagGoods/btnAddType', {
				goodsString : userCodes.join(','),
				temp:"5"
			}, function(data){
				js.showMessage(data.message);
				page();
			});
		});
	}else{
		js.showMessage('请在列表选中要确定归类 的商品');
	}
	return false;
});
$('#btnDelJinxuan').click(function(){
	var userCodes = $('#dataGrid').dataGrid('getSelectRows');
	if (userCodes != null && userCodes.length > 0){
		js.confirm('确认要商品删除归类吗？', function(){
			js.ajaxSubmit('${ctx}/ztTagGoods/btnDelType', {
				goodsString : userCodes.join(','),
				temp:"5"
			}, function(data){
				js.showMessage(data.message);
				page();
			});
		});
	}else{
		js.showMessage('请在列表选中要确定归类 的商品');
	}
	return false;
});

$('#btnDelZhuanc').click(function(){
	var userCodes = $('#dataGrid').dataGrid('getSelectRows');
	if (userCodes != null && userCodes.length > 0){
		js.confirm('确认要商品删除归类吗？', function(){
			js.ajaxSubmit('${ctx}/ztBeiGoods/btnDelType', {
				goodsString : userCodes.join(','),
				temp:"3"
			}, function(data){
				js.showMessage(data.message);
				page();
			});
		});
	}else{
		js.showMessage('请在列表选中要确定归类 的商品');
	}
	return false;
});
$('#btnDelBanner').click(function(){
	var userCodes = $('#dataGrid').dataGrid('getSelectRows');
	if (userCodes != null && userCodes.length > 0){
		js.confirm('确认要商品删除归类吗？', function(){
			js.ajaxSubmit('${ctx}/ztBeiGoods/btnDelType', {
				goodsString : userCodes.join(','),
				temp:"4"
			}, function(data){
				js.showMessage(data.message);
				page();
			});
		});
	}else{
		js.showMessage('请在列表选中要确定归类 的商品');
	}
	return false;
});

$(function() {
	
	// 初始化第一类型
	initAddress();

	// 更改省份后的操作
	$("select[name='oneType']").change(function() {

		var provCode = $("select[name='oneType']").val();

		getCity(provCode);

	});

	// 更改城市后的操作
	$("select[name='twoType']").change(function() {
		var cityCode = $("select[name='twoType']").val();
		getArea(cityCode);
	});

});

function initAddress() {

	var firstProvCode;
	// ajax请求所有省份
	$.get("${ctx}/goodsType/getType", {
		method : "initOne"
	}, function(data) {
		$("select[name='oneType']").empty();
		
		$("select[name='oneType']").append(
				"<option value=''>一级分类</option>");
		
		$.each(data, function(i, d) {
			
			$("select[name='oneType']").append(
					"<option value='"+d.viewCode+"'>" + d.name
							+ "</option>");
		});

		// 获取第一个省份的code
		firstProvCode = data[0].viewCode;
		// 根据第一个省份code获取对应城市列表
		getCity(firstProvCode);
	}, 'json');

}

//获取对应城市列表（里面包括获取第一个城市的区县列表）
function getCity(viewCode) {

	var firstCityCode;

	// ajax请求所有市级单位
	$.get("${ctx}/goodsType/getType", {
		method : "getTwo",
		viewCode : viewCode
	}, function(data) {

		// 先清空城市下拉框
		$("select[name='twoType']").empty();
		$("select[name='twoType']").append(
		"<option value=''>二级分类</option>");
		$.each(data, function(i, d) {
			$("select[name='twoType']").append(
					"<option value='"+d.viewCode+"'>" + d.name
							+ "</option>");
		});
		
		// 获取第一个城市的code
		firstCityCode = data[0].viewCode;
		// 根据第一个城市code获取对应区县列表
		getArea(firstCityCode);
		
	}, 'json');
}

function getArea(viewCode) {

	// ajax请求所有区县单位
	$.get("${ctx}/goodsType/getType", {
		method : "getThree",
		viewCode : viewCode
	}, function(data) {
		
		// 先清空区县下拉框
		$("select[name='threeType']").empty();
		$("select[name='threeType']").append(
		"<option value=''>三级分类</option>");
		$.each(data, function(i, d) {
			$("select[name='threeType']").append(
					"<option value='"+d.viewCode+"'>" + d.name
							+ "</option>");
		});
	}, 'json');
}



// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [ 
		{header:'${text('渠道')}', name:'spotid',  width:90, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('zt_spotid_type')}, val, '${text('自购')}', true);
		}},          
		{header:'${text('栏目类型')}', name:'goodstemp',  width:120, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('zt_goodstemp_type')}, val, '${text('分类')}', true);
		}},
		{header:'${text('商品类型')}', name:'typeName', width:120, align:"center"},
		/*{header:'${text('品牌')}', name:'brandName', width:100, align:"center"},*/
		{header:'${text('商品编号')}', name:'code', index:'a.code', width:110, align:"center"},
		
		{header:'${text('商品名')}', name:'title', width:230, align:"center"},

		{header:'${text('参考价格')}', name:'origPrice',  width:170, align:"center",formatter: function(val, obj, row, act){
				var actions = [];
				actions.push('协议:'+row.supplyPrice+'<br/>市场:'+row.origPrice+'<br/>实时:'+row.jdSprice+'');
				return actions.join('');
			}},
		{header:'${text('出售价格')}', name:'discountPrice',  width:170, align:"center",formatter: function(val, obj, row, act){
				var actions = [];
				actions.push('普通:'+row.commonPrice+'<br/>会员:'+row.discountPrice+'');
				return actions.join('');
			}},

		{header:'${text('折扣')}', name:'depo',  width:130, align:"center",formatter: function(val, obj, row, act){
				var actions = [];
				var jdDepo;
				var scDepo;
				if(row.jdSprice>0){
					jdDepo='实时:'+((row.supplyPrice/row.jdSprice)*100).toFixed(2)+'%<br/>';
				}else if(row.jdSprice==0){
					jdDepo='<font color="red">实时:0%</font><br/>';
				}else {
					jdDepo='<font color="red">实时:'+((row.supplyPrice/row.jdSprice)*100).toFixed(2)+'%</font><br/>';
				}

				if(row.origPrice>0) {
					scDepo = '市场:' + ((row.supplyPrice / row.origPrice) * 100).toFixed(2) + '%<br/>';
				}else if(row.origPrice==0){
					scDepo = '<font color="red">市场:0%</font><br/>';
				}else {
					scDepo ='<font color="red">市场:' + ((row.supplyPrice / row.origPrice) * 100).toFixed(2) + '%</font><br/>';

				}


				actions.push(scDepo+jdDepo);
				return actions.join('');
			}},

		{header:'${text('差额')}', name:'diff', width:120, align:"center",formatter: function(val, obj, row, act){
				var actions = [];
				var jdDiff=	(row.jdSprice-row.supplyPrice).toFixed(2)<=0?'<font color="red">实时:'+(row.jdSprice-row.supplyPrice).toFixed(2)+'</font><br/>':'实时:'+(row.jdSprice-row.supplyPrice).toFixed(2)+'<br/>';
				var scDiff=(row.origPrice-row.supplyPrice).toFixed(2)<=0?'<font color="red">市场:'+(row.origPrice-row.supplyPrice).toFixed(2)+'</font><br/>':'市场:'+(row.origPrice-row.supplyPrice).toFixed(2)+'<br/>';

				actions.push(scDiff+jdDiff);
				return actions.join('');
			}},
		{header:'${text('图片')}', name:'img',  width:80, align:"center",formatter: function(val, obj, row, act){
			return '<img style="width:36px;height:36px;" src="'+val+'"></img>';
		}},
		
		/* {header:'${text('库存')}', name:'count', index:'a.count', width:90, align:"center"}, */
		{header:'${text('已售')}', name:'soldCount', width:90, align:"center"},
		
		{header:'${text('上架状态')}', name:'sjStatus', width:120, align:"center", formatter: function(val, obj, row, act){
			var sj = js.getDictLabel(${@DictUtils.getDictListJson('zt_sj_type')}, val, '${text('未上架')}', true);
			if(row.sjStatus=='0'){
				sj='<font color="#FF7F00">'+sj+'</font>';
			}else if(row.sjStatus=='1'){
				//sj='<font color="green">'+sj+'</font>';
			}else if(row.sjStatus=='2'){
				sj='<font color="red">'+sj+'</font>';
			}
			return sj;
		}},
		
		// {header:'${text('类型状态')}', name:'state', width:120, align:"center", formatter: function(val, obj, row, act){
		// 	var sj = js.getDictLabel(${@DictUtils.getDictListJson('zt_sj_type')}, val, '${text('未上架')}', true);
		// 	if(row.state=='0'){
		// 		sj='<font color="#FF7F00">'+sj+'</font>';
		// 	}else if(row.state=='1'){
		// 		//sj='<font color="green">'+sj+'</font>';
		// 	}else if(row.state=='2'){
		// 		sj='<font color="red">'+sj+'</font>';
		// 	}
		// 	return sj;
		// }},
		{header:'${text('定价模式')}', name:'actions', width:135,align:"center", sortable:false, title:false, formatter: function(val, obj, row, act){	
			var actions = [];
			<% if(hasPermi('ztBeiGoods:ztBeiGoodsData:edit')){ %>
				var t='';
			if(row.tag=='0'){//折扣定价   1是毛利额定价   2是自定义定价
				t="折扣定价";
			}else if(row.tag=='1'){
				t='毛利额定价';
			}else if(row.tag=='2'){
				t='<font color="green">自定义定价</font>';
			}else if(row.tag=='3'){
				t='<font color="red">不符合定价</font>';
			}
			actions.push(''+t+'');
				
				actions.push('<p/><a href="${ctx}/ztBeiGoods/tag?id='+row.id+'" class="btnList" title="${text('点击更换定价模式')}" data-confirm="${text('确认要更换定价模式吗？')}">更换定价</a>&nbsp;');
			<% } %>
			return actions.join('');
		}},
		/*{header:'${text('更新时间')}', name:'createDate',  width:160, align:"center"},
		*/
		{header:'${text('操作')}', name:'actions', width:140, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('ztBeiGoods:ztBeiGoodsData:edit')){ %>
				
				actions.push('<a href="${ctx}/ztBeiGoods/form?id='+row.id+'" class="btnList" title="${text('编辑商品')}"><i class="fa fa-pencil"></i></a>&nbsp;');
				
				actions.push('<a href="${ctx}/ztBeiGoods/delete?id='+row.id+'" class="btnList" title="${text('删除商品')}" data-confirm="${text('确认要删除该数据吗？')}"><i class="fa fa-trash-o"></i></a>&nbsp;');
				
				if (row.sjStatus == '3'){
					actions.push('<a href="${ctx}/ztBeiGoods/enable?id='+row.id+'" class="btnList" title="${text('商品上架')}" data-confirm="${text('确认要上架该商品吗？')}"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');
				}
				
			<% } %>
			return actions.join('');
		}},
	/*	{header:'${text('评论')}', name:'actions', width:85,align:"center", sortable:false, title:false, formatter: function(val, obj, row, act){
			return '<a href="${ctx}/ztComment/list?ztGoods.id='+row.id+'" class="btnList" title="${text('商品评论')}">评论</a>';
		}}*/
		
	],
	showCheckbox: true,
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});

$('#btnDelUser').click(function(){
	var userCodes = $('#dataGrid').dataGrid('getSelectRows');
	if (userCodes != null && userCodes.length > 0){
		js.confirm('确认要上架商品吗？', function(){
			js.ajaxSubmit('${ctx}/ztBeiGoods/batchEnable', {
				
				goodsString : userCodes.join(',')
			}, function(data){
				js.showMessage(data.message);
				page();
			});
		});
	}else{
		js.showMessage('请在列表选中要确定上架的商品');
	}
	return false;
});

function priceUpdate(data){
	    console.log(data);
		js.confirm('定价规则已更改，是否确认刷新定价吗？', function(){
			js.ajaxSubmit('${ctx}/ztBeiGoods/priceUpdate', {
				goodsString:data
			}, function(data){
				js.showMessage(data.message);
				page();
			});
		});
	
	return false;
}

$('#btnTag').click(function(){
	var userCodes = $('#dataGrid').dataGrid('getSelectRows');
	if (userCodes != null && userCodes.length > 0){
		js.confirm('确认要更换商品定价吗？', function(){
			js.ajaxSubmit('${ctx}/ztTagGoods/btnTag', {
				goodsString : userCodes.join(',')
			}, function(data){
				js.showMessage(data.message);
			});
		});
	}else{
		js.showMessage('请在列表选中要确定更换定价的商品');
	}
	return false;
});
</script>